package com.itheima.common;

import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@RestControllerAdvice
@Slf4j
public class ProjectExceptionAdvice {
    @ExceptionHandler(Exception.class)
    public R doException(Exception e){
        if (e.getMessage().contains("Duplicate entry")){
            return R.error("菜品重复");
        }
      log.info("逮到一个异常:{}",e.toString());
      return R.error("出现异常了");
    }
}
